"use strict";
cc._RF.push(module, 'e5ff3s50vlAuILfIKTu5uVl', 'Boomerang');
// scripts/Boomerang.js

"use strict";

var t = require;
var e = module;
var o = exports;

var _i,
    n = void 0 && (void 0).__extends || (_i = function i(t, e) {
  return (_i = Object.setPrototypeOf || {
    __proto__: []
  } instanceof Array && function (t, e) {
    t.__proto__ = e;
  } || function (t, e) {
    for (var o in e) {
      Object.prototype.hasOwnProperty.call(e, o) && (t[o] = e[o]);
    }
  })(t, e);
}, function (t, e) {
  function o() {
    this.constructor = t;
  }

  _i(t, e), t.prototype = null === e ? Object.create(e) : (o.prototype = e.prototype, new o());
}),
    a = void 0 && (void 0).__decorate || function (t, e, o, i) {
  var n,
      a = arguments.length,
      r = a < 3 ? e : null === i ? i = Object.getOwnPropertyDescriptor(e, o) : i;
  if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(t, e, o, i);else for (var s = t.length - 1; s >= 0; s--) {
    (n = t[s]) && (r = (a < 3 ? n(r) : a > 3 ? n(e, o, r) : n(e, o)) || r);
  }
  return a > 3 && r && Object.defineProperty(e, o, r), r;
};

Object.defineProperty(o, "__esModule", {
  value: !0
});

var r = t("GameConstant"),
    s = t("Util"),
    l = t("Rotation"),
    c = t("Global"),
    d = cc._decorator,
    h = d.ccclass,
    p = d.property,
    u = function (t) {
  function e() {
    var e = null !== t && t.apply(this, arguments) || this;
    return e.collider = null, e.speed = 0, e.degree = 0, e._posNoe = null, e._isRollback = !1, e.isAction = !1, e;
  }

  return n(e, t), e.prototype.initItem = function (t, e, o, i, n, a, d) {
    var h = this;
    this.degree = n / 180 * Math.PI, this.node.opacity = 255, this.node.scaleX = o, this.node.position = i, this.node.angle = n, this.collider.enabled = !0, this.speed = 1500 / s.Util.attackSpeed(1, e), this.collider.tag = t, this.setScale(e == r.Collide_Car_Tag.Right, o), this._posNoe = a, this._isRollback = !1, this.isAction = !0, this.scheduleOnce(function () {
      h._isRollback = !0, h.collider.enabled = !0, h.node.getChildByName("boom").getComponent(l["default"]).overturn();
    }, s.Util.attackSpeed(.5, e)), this.scheduleOnce(function () {
      d.back(), s.Util.objectPool.putNodeIntoNodePool(c.PoolKey.Boomerang, h.node);
    }, s.Util.attackSpeed(1, e));
  }, e.prototype.setScale = function (t, e) {
    var o = 1;
    o = r.Cur_Game_Type == r.Game_Type.PK ? r.Game_Type_Scale.PK : 1, o = e < 0 ? -o : o, this.node.scale = t ? -o : o;
  }, e.prototype.getPos = function () {
    var t = this._posNoe.convertToWorldSpaceAR(cc.v3(0, 0, 0));

    return cc.find("Canvas").convertToNodeSpaceAR(t);
  }, e.prototype.lookAtDirection = function () {
    var t,
        e = (t = this.getPos().sub(this.node.position).normalize()).signAngle(cc.v2(1, 0)) / Math.PI * 180;
    return this.node.rotation = cc.misc.lerp(this.node.rotation, e, .2), t;
  }, e.prototype.update = function (t) {
    this.isAction && (this._isRollback ? (this.node.x += this.speed * t * this.lookAtDirection().x, this.node.y += this.speed * t * this.lookAtDirection().y) : this.node.scaleX >= 0 ? (this.node.x += this.speed * t * Math.cos(this.degree), this.node.y += this.speed * t * Math.sin(this.degree)) : (this.node.x -= this.speed * t * Math.cos(this.degree), this.node.y -= this.speed * t * Math.sin(this.degree)));
  }, a([p(cc.Collider)], e.prototype, "collider", void 0), a([h], e);
}(cc.Component);

o["default"] = u;

cc._RF.pop();